import java.io.*;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new FileReader("文件1.txt"))) {
            String line;
            while ((line = reader.readLine()) != null) {
                // 添加读取到的行内容
                stringBuilder.append(line).append("\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        String fiedData = stringBuilder.toString().toUpperCase();
        try (BufferedWriter writer = new BufferedWriter(new FileWriter("文件2.txt"))) {
            writer.write(fiedData);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try (BufferedReader reader1 = new BufferedReader(new FileReader("文件2.txt"))) {
            String line;
            while ((line = reader1.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main2(String[] args) throws IOException {
      StringBuilder stringBuilder =new StringBuilder();
      try(BufferedReader reader =new BufferedReader(new FileReader("文件1.txt"))){
          String line;
          while((line=reader.readLine())!=null){
              stringBuilder.append("\n");
          }
      }catch (IOException e){
          e.printStackTrace();
      }
      String fiedData = stringBuilder.toString().toUpperCase();
      try(BufferedWriter writer =new BufferedWriter(new FileWriter("文件2.txt"))){
          writer.write(fiedData);
      }catch (IOException e){
          e.printStackTrace();
      }
      try(BufferedReader reader1 =new BufferedReader(new FileReader("文件2.txt"))){
          String line;
          while((line=reader1.readLine())!=null){
              System.out.println(line);
          }
      }catch (IOException e){
          e.printStackTrace();
      }
    }
    public static void main1(String[] args) throws IOException {
        Scanner scanner =new Scanner(System.in);
        try(BufferedWriter writer = new BufferedWriter(new FileWriter("number.txt"))){
            System.out.println("请输入10个正数，每个正数占一行:");
            for (int i = 0; i < 10; i++) {
                int num =scanner.nextInt();
                writer.write(String.valueOf(num));
                writer.newLine();
            }
        }catch (IOException e){
            e.printStackTrace();
        }
        try(BufferedReader reader =new BufferedReader(new FileReader("number.txt"))){
                System.out.println("从文件中读取的内容如下:");
                String line;
                while((line=reader.readLine())!=null){
                    System.out.println(line);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            scanner.close();
        }
    }
}
